#include "N1Data.h"
#include "N1Lib.h"



N1Data::N1Data()
{
}

N1NAME_DEF(N1Data)

N1Data::N1Data(N1UInt32 capacity) : m_buffer(capacity)
{
}

N1Data::N1Data(const void* data, N1UInt32 size) : m_buffer(size)
{
    memcpy(m_buffer.getPtr(), data, size);
}

N1Data::~N1Data()
{
}

void N1Data::attach(void* data, uint32 size)
{
    m_buffer.attach(data, size);
}

void N1Data::detach()
{
    m_buffer.detach();
}

void N1Data::setSize(N1UInt32 newSize)
{
    m_buffer.setBufferSize(newSize);
}

void N1Data::increaseSize(N1UInt32 add)
{
    m_buffer.appendData(add);
}

void N1Data::addMemory(const void* ptr, uint32 size)
{
    char*  dataEnd = m_buffer.getPtr() + m_buffer.getDataSize();
    increaseSize(size);
    memcpy(dataEnd, ptr, size);
}

void N1Data::addByte(uint8 b)
{
    addMemory(&b, sizeof(b));
}

void N1Data::addShort(uint16 s)
{
    s = N1H2N16(s);
    addMemory(&s, sizeof(s));
}

void N1Data::addInt(uint32 i)
{
    i = N1H2N32(i);
    addMemory(&i, sizeof(i));
}
 
#ifdef N1LIB_SELFTEST





#endif //N1LIB_SELFTEST
